package com.cloudkinto.vo.wr.trial;

import com.cloudkinto.common.utils.MathUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@Data
@NoArgsConstructor
public class TrialFreightRes {
    @ApiModelProperty("是否匹配到报价 重量段 分区未匹配 依旧可以继续匹配操作费")
    private boolean successFlag;

    @ApiModelProperty("是否下单成功 重量段 分区未匹配 就不能下单成功 但是如果没有报价方案就可以下单成功")
    private boolean placeOrderFlag;
    @ApiModelProperty("下单失败原因")
    private String placeOrderMsg;
    @ApiModelProperty("下单失败原因详情")
    private String placeOrderDetailMsg;

    @ApiModelProperty("基础运费")
    private double logBaseFee;
    @ApiModelProperty("附加费")
    private double surchargeFee;
    private Long channelId;
    @ApiModelProperty("物流渠道编码")
    private String channelCode;
    @ApiModelProperty("物流渠道名称")
    private String channelName;
    @ApiModelProperty("承运商")
    private String carrier;
    @ApiModelProperty("币种")
    private String currencyCode;

    @ApiModelProperty("计费种")
    private double chargeWeight;
    //    private double chargeWeightBs;
    @ApiModelProperty("体积重")
    private String volumeWeight;
    @ApiModelProperty("单位")
    private String sizeUnit;
    //    private double volumeWeightBs;
    @ApiModelProperty("失败原因")
    private String failMsg;
    @ApiModelProperty("费用详情")
    private List<SurchargeFeeRes> surchargeList = new ArrayList<>();

    private Long whId;
    // 仓库类型 0自营仓 1代理仓
    private Integer warehouseType;
    private String warehouseCode;


    public TrialFreightRes(Long channelId, String channelCode, String channelName, String failMsg ) {
        this.successFlag = false;
        this.placeOrderFlag = true;
        this.channelId = channelId;
        this.channelCode = channelCode;
        this.channelName = channelName;
        this.failMsg = failMsg;
    }

    public TrialFreightRes(Long channelId, String channelCode, String channelName, String failMsg, String placeOrderMsg, String placeOrderDetailMsg) {
        this.successFlag = false;
        this.placeOrderFlag = false;
        this.channelId = channelId;
        this.channelCode = channelCode;
        this.channelName = channelName;
        this.failMsg = failMsg;
        this.placeOrderMsg = placeOrderMsg;
        this.placeOrderDetailMsg = placeOrderDetailMsg;
    }

    public TrialFreightRes(Long channelId, String channelCode, String channelName, String carrier, String currencyCode, double chargeWeight, String volumeWeight, String sizeUnit) {
        this.successFlag = true;
        this.placeOrderFlag = true;
        this.channelId = channelId;
        this.channelCode = channelCode;
        this.channelName = channelName;
        this.carrier = carrier;
        this.currencyCode = currencyCode;
        this.chargeWeight = chargeWeight;
        this.volumeWeight = volumeWeight;
        this.sizeUnit = sizeUnit;
    }

    public TrialFreightRes(String placeOrderMsg, String placeOrderDetailMsg) {
        this.successFlag = false;
        this.placeOrderFlag = false;
        this.placeOrderMsg = placeOrderMsg;
        this.placeOrderDetailMsg = placeOrderDetailMsg;
    }

    public double getLogBaseFee() {
        return MathUtils.numberFormat(logBaseFee,4);
    }


}
